import random

# number = random.randint(3,18)
# 猜的次数
times = 0
# 猜对次数
scores = 0
# 标识符用于跳出循环
flag = 0
guess_side = ""

# if 3<=number<=10:
#     guess_side = "小"
# else:
#     guess_side = "大"


while flag == 0:
    number = random.randint(3, 18)
    if 3 <= number <= 10:
        guess_side = "小"
    elif 11 <= number <= 18:
        guess_side = "大"

    guess = input("请输入：")
    if guess == "大":
        if guess == guess_side:
            scores += 1
            print("Congratulations!")
        elif guess != guess_side:
            print("Sorry,please try it again.")
    elif guess == "小":
        if guess == guess_side:
            scores += 1
            print("Congratulations!")
        elif guess != guess_side:
            print("Sorry,please try it again.")
    times += 1
    # if guess==guess_side:
    #     scores += 1
    #     print("Congratulations!")
    #     times += 1
    # elif guess != guess_side:
    #     print("Sorry,please try it again.")
    if guess == "exit":
        rating = scores/(times-1)
        print('您的胜率是{:.2f}%'.format(rating*100))
        break
